package main

import (
	"fmt"

	"math"

)

/*
练习1：
父类：人类
	name，age
	eat(),printInfo()

子类：学生类
	school
	重写eat(),新增study()

练习2：
定义一个类：Point
	x，y，z轴
创建点的对象：
	两个点

定义函数，方法，求两点之间的距离


练习3：定义学生类
	姓名，年龄，性别，英语成绩，语文成绩，数学成绩
	方法：
		求总分()
		求平均分()
		打印学生信息()
 */

type student1 struct {
	name string
	age int
	engscore int
	cnscore int
	numscore int
}

func (s student1) zf()  {
	fmt.Println("总分是：",s.engscore+s.cnscore+s.numscore)
}

func (s student1) pjf()  {
	fmt.Println("平均分是：",(s.engscore+s.cnscore+s.numscore)/3)
}

func (s student1) printstudentInfo()  {
	fmt.Printf("同学%s，年龄:%d,英语成绩：%d,语文成绩：%d,数学成绩：%d,平均成绩：%d\n",s.name,s.age,s.engscore,s.cnscore,s.numscore,(s.engscore+s.cnscore+s.numscore)/3)
}
type Person struct {
	name string
	age int

}
type student struct {
	Person
	school string
}

func (p Person) eat()  {
	fmt.Printf("姓名：%s，在吃ing...\n",p.name)
}

func (p Person) printInfo()  {
	fmt.Printf("姓名：%s,年龄：%d\n",p.name,p.age)
}

func (s student) eat()  {
	fmt.Printf("%s同学在吃.....\n",s.name)
}

func (s student)  study() {
	fmt.Printf("%s，今年%d,目前在%s学习中．．．．\n",s.name,s.age,s.school)

}


type Point struct {
	x,y,z float64
	//x-y
}

func (j Point) qiujuli(j2 Point) float64 {
	//fmt.Println(j.x,j.y,j.z,j2.x,j2.y,j2.z)
	dis:=math.Sqrt((j.x-j2.x)*(j.x-j2.x)+(j.y-j2.y)*(j.y-j2.y)+(j.z-j2.z)*(j.z-j2.z))
	//fmt.Println(dis)
	return dis
}
func getdistance(j1,j2 Point) {
	//fmt.Printf("%T,%T,%T,%T,%T,%T",x1,x2,y1,y2,z1,z2)
	dis:=math.Sqrt((j1.x-j2.x)*(j1.x-j2.x)+(j1.y-j2.y)*(j1.y-j2.y)+(j1.z-j2.z)*(j1.z-j2.z))
	fmt.Println(dis)
}


func main()  {
	p1:=Person{"王二狗",30}
	p1.eat()
	p1.printInfo()

	s1:=student{Person{"小王",18},"清华"}
	s1.eat()
	s1.printInfo()

	s1.eat()
	s1.study()

	j1:=Point{0,0,0}
	j2:=Point{2.4,4.1,6.3}

	//juli:=math.sqrt((j1.x-j2.x)*(j1.x-j2)+(j1.y-j2.y)*(j1.y-j2.y)+(j1.z-j2.z)*(j1.z-j2.z))


	s2:=student1{"王二狗　",13,89,68,30}
	s2.zf()
	s2.pjf()
	s2.printstudentInfo()

	getdistance(j1,j2)

	res1:=j1.qiujuli(j2)
	fmt.Println(res1)


}
